#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAX = 100000;

struct Student {
	char id[10];  // 准考证号
	int talent;  // 才
	int virtue;  // 德
	int sum;  // 总分
	int flag;  // 类别: 1, 2, 3, 4, 5
}stu[MAX+10];

bool cmp(Student a, Student b) {
	if (a.flag != b.flag) return a.flag < b.flag;
	else if (a.sum != b.sum) return a.sum > b.sum;
	else if (a.virtue != b.virtue) return a.virtue > b.virtue;
	else return strcmp(a.id, b.id) < 0;
}

int main() {
	int n, L, H;
	int count;
	scanf("%d%d%d", &n, &L, &H);
	count = n;
	for (int i = 0; i < n; i++) {
		scanf("%s%d%d", stu[i].id, &stu[i].virtue, &stu[i].talent);
		stu[i].sum = stu[i].virtue + stu[i].talent;
		if (stu[i].virtue < L || stu[i].talent < L) {
			stu[i].flag = 5;
			count--;
		} else if (stu[i].virtue >= H && stu[i].talent >= H) stu[i].flag = 1;
		else if (stu[i].virtue >= H && stu[i].talent < H) stu[i].flag = 2;
		else if (stu[i].virtue >= stu[i].talent) stu[i].flag = 3;
		else stu[i].flag = 4;
	}
	sort(stu, stu+n, cmp);
	printf("%d\n", count);
	for (int i = 0; i < count; i++) {
		printf("%s %d %d\n", stu[i].id, stu[i].virtue, stu[i].talent);
	}

	return 0;
}

